- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
65 lines (56 loc) · 1.76 KB
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#using <System.dll>
#using <System.Xml.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.Data.dll>
usingnamespaceSystem;
usingnamespaceSystem::Data;
usingnamespaceSystem::Drawing;
usingnamespaceSystem::Windows::Forms;
public ref classForm1: publicForm
{
protected:
TextBox^ textBox1;
// <Snippet1>
private:
voidBindTextBoxProperties()
{
// Clear the collection before adding new Binding objects.
textBox1->DataBindings->Clear();
// Create a DataTable containing Color objects.
DataTable^ t = MakeTable();
/* Bind the Text, BackColor, and ForeColor properties
to columns in the DataTable. */
textBox1->DataBindings->Add( "Text", t, "Text" );
textBox1->DataBindings->Add( "BackColor", t, "BackColor" );
textBox1->DataBindings->Add( "ForeColor", t, "ForeColor" );
}
DataTable^ MakeTable()
{
/* Create a DataTable with three columns.
Two of the columns contain Color objects. */
DataTable^ t = gcnew DataTable( "Control" );
t->Columns->Add( "BackColor", Color::typeid );
t->Columns->Add( "ForeColor", Color::typeid );
t->Columns->Add( "Text" );
// Add three rows to the table.
DataRow^ r;
r = t->NewRow();
r[ "BackColor" ] = Color::Blue;
r[ "ForeColor" ] = Color::Yellow;
r[ "Text" ] = "Yellow on Blue";
t->Rows->Add( r );
r = t->NewRow();
r[ "BackColor" ] = Color::White;
r[ "ForeColor" ] = Color::Green;
r[ "Text" ] = "Green on white";
t->Rows->Add( r );
r = t->NewRow();
r[ "BackColor" ] = Color::Orange;
r[ "ForeColor" ] = Color::Black;
r[ "Text" ] = "Black on Orange";
t->Rows->Add( r );
return t;
}
// </Snippet1>
};